
;*******************************************************
;
;	SCSI Driver 'Flush' Filter
;
;	Written by Matt Gulick.		Started June 13,1988
;
;	Copyright Apple Computer, Inc. 1988-90
;
;*******************************************************

;*******************************************************
;
;	This file contains the subroutines needed by the
;	SCSI Driver to respond to the Flush call number
;	$0007.  In a Block Device Driver this will return a
;	Driver Bad Request error and perform no function.
;	In the case of a Character device however, this will
;	need to request that the target device finalize what
;	it was doing and flush it's buffers.
;
;*******************************************************

;*******************************************************
;
;	Revision History:
;
;*******************************************************

;	June 13,	1988	File started.
;	June 20,	1988	Added Register Status in comments
;
;	January 3	1990	Added Character Device Code

				STRING		PASCAL
				BLANKS		OFF
				PAGESIZE	70
				PRINT		NOGEN
				PRINT		NOMDIR
				MACHINE		M65816

				PRINT		OFF

				INCLUDE		'scsihd.equates'
				INCLUDE		'M16.MEMORY'
				INCLUDE		'M16.UTIL'
				PRINT		ON

				EJECT

				IF			block_dvc = true\
				AND			character_dvc = false		THEN
			
;*******************************************************
;
;	This routine is used as the Flush code for a Block
;	Device Driver.
;
;	Inputs:		None.
;
;	Outputs:	Acc			=	0
;				Carry		=	0
;				Y register	=	Unspecified
;				X register	=	Unspecified
;				P register	=	0=M=X=e
;				Direct Page	=	GS/OS Direct Page
;				Data Bank	=	Ours
;
;	Errors:		DRVR_BAD_REQ.
;
;*******************************************************

				ENDIF

;-------------------------------------------------------------------------------

				IF			character_dvc = true\
				AND			block_dvc = false		THEN
             	
;*******************************************************
;
;	This routine is used as the Flush code for a
;	Character Device Driver.  This code is commented out
;	so that is available to any one who uses this SCSI
;	Driver Skeleton.
;
;	Inputs:		None.
;
;	Outputs:	Acc			=	Error
;				Carry		=	Set or Clear
;				Y register	=	Unspecified
;				X register	=	Unspecified
;				P register	=	0=M=X=e
;				Direct Page	=	GS/OS Direct Page
;				Data Bank	=	Ours
;
;	Errors:		Device not open Error	$0023
;				For other errors see Spec.
;
;*******************************************************

				ENDIF

;-------------------------------------------------------------------------------

				EXPORT	Flush
Flush			PROC

;-------------------------------------------------------------------------------

				IF			block_dvc = true\
				AND			character_dvc = false		THEN

				lda		#drvr_bad_req
				sec
				rts

				ENDIF

;-------------------------------------------------------------------------------

				IF			character_dvc = true\
				AND			block_dvc = false		THEN
												;
												; Is the device online?
												;
				ldy		#dib.dvcflag

				lda		[dib_ptr],y
				and		#dvc_online
				bne		@flush					;Yes.
												;
												; Device is currently offline.
												;
				lda		#drvr_off_line
				sec
				rts
												;
												; Check Open Flag
												;
@flush			lda		|open_flag
				beq		@dvc_closed

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

				Insert Your Code Here.

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

				lda		#$0000
				clc
				rts

@dvc_closed		lda		#$drvr_not_open
				sec
				rts

				ENDP

				END

				EJECT
